package com.kefu.boss.service;

import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
import com.kefu.boss.mapper.BossUserRoleMapper;
import com.kefu.boss.model.BossRole;
import com.kefu.boss.model.BossUserRole;
import com.kefu.common.service.AbstractKefuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class BossUserRoleService extends AbstractKefuService<BossUserRole> {
    @Resource
    protected BossUserRoleMapper bossUserRoleMapper;
    DefaultIdentifierGenerator generator = new DefaultIdentifierGenerator();
    public void batchAdd(List<BossUserRole> userRoles) {
        userRoles.stream().forEach(menu->{
            menu.setId(generator.nextId(menu));
        });
        bossUserRoleMapper.batchAdd(userRoles);
    }

    public void deleteByUserId(String userId) {
        bossUserRoleMapper.deleteByUserId(userId);
    }

    public void deleteByRoleId(String roleId) {
        bossUserRoleMapper.deleteByRoleId(roleId);
    }

    public List<BossRole> getRoleList(String userId) {

        return bossUserRoleMapper.getRoleList(userId);
    }
}
